
// Main header
#include "../Main.h"

//My Header
#include "StaticText.h"

//Fridge
#include "../TextRender.h"

StaticText::StaticText( Widget* pxWidget ) : Panel( pxWidget )
{
	m_uTextColour = 0x000000FF;
	m_szText[0] = 0;
	m_bAutoSizes = false;
	SetColour( 0x00000000 );
}

StaticText::~StaticText()
{

}

void StaticText::SetText( const char* szText )
{
	if( szText )
	{
		strncpy( m_szText, szText, STATIC_TEXT_MAX_LENGTH );
		UpdateAutoSize();
	}
}

void StaticText::Render()
{
	Panel::Render();

	if( m_szText[0] )
	{
		TextRender::SetColour( m_uTextColour );
		TextRender::SetFont( FONT_SANS_12 );
		TextRender::Print( m_szText, GetResizedX(), GetResizedY() );
	}
}

void StaticText::SetAutoSizes( const bool bAutoSizes )
{
	m_bAutoSizes = bAutoSizes;

	UpdateAutoSize();
}

void StaticText::UpdateAutoSize()
{
	if( m_bAutoSizes )
	{
		TextRender::GetRenderSize( m_szText, m_uWidth, m_uHeight );
	}
}

// eof
